/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.cv4j.codeview;

/**
 * CodeDemo
 *
 * @since 2021-05-19
 */
public class CodeDemo {
    /**
     * getDemo1
     *
     * @return String
     */
    public static String getDemo1() {
        CodeBuilder codeBuilder = new CodeBuilder();
        codeBuilder.append("CV4JImage cv4JImage = new CV4JImage(bitmap);")
            .lineFeed()
            .append("image2.setImageBitmap(cv4JImage.toBitmap());");
        return codeBuilder.build();
    }

    /**
     * getDemo2
     *
     * @return String
     */
    public static String getDemo2() {
        CodeBuilder codeBuilder = new CodeBuilder();
        codeBuilder.appendHljsKeyword("RxImageData")
            .appendHljsName(".bitmap")
            .append("(")
            .appendHljsKeyword("bitmap")
            .append(")")
            .appendHljsName(".into")
            .appendHljsKeyword("image2")
            .append(");");
        return codeBuilder.build();
    }

    /**
     * getDemo3
     *
     * @return String
     */
    public static String getDemo3() {
        CodeBuilder codeBuilder = new CodeBuilder();
        codeBuilder.append("CompositeFilters compositeFilters = ")
            .appendHljsKeyword("new")
            .append(" CompositeFilters();")
            .append(System.lineSeparator())
            .append("Bitmap newBitmap = compositeFilters")
            .append(System.lineSeparator())
            .append(".addFilter(")
            .appendHljsKeyword("new")
            .append(" NatureFilter())")
            .append(System.lineSeparator())
            .append(".addFilter(")
            .appendHljsKeyword("new")
            .append(" SpotlightFilter())")
            .append(System.lineSeparator())
            .append(".filter(new")
            .appendHljsKeyword("new")
            .append(" CV4JImage(bitmap).getProcessor())")
            .append(System.lineSeparator())
            .append(".getImage()")
            .append(System.lineSeparator())
            .append(".toBitmap();")
            .append(System.lineSeparator())
            .append(System.lineSeparator())
            .append("image3.setImageBitmap(newBitmap);");
        return codeBuilder.build();
    }

    /**
     * getDemo4
     *
     * @return String
     */
    public static String getDemo4() {
        CodeBuilder codeBuilder = new CodeBuilder();
        codeBuilder.appendHljsName("cv4j")
            .append(" {")
            .append(System.lineSeparator())
            .appendHljsAttribute("bitmap")
            .append(" = BitmapFactory.decodeResource(resources, R.drawable.test_io)")
            .append(System.lineSeparator())
            .append("    filter = NatureFilter()")
            .append(System.lineSeparator())
            .append("    imageView = image")
            .append(System.lineSeparator())
            .append("}");
        return codeBuilder.build();
    }

    /**
     * getDemo5
     *
     * @return String
     */
    public static String getDemo5() {
        CodeBuilder codeBuilder = new CodeBuilder();
        codeBuilder.appendHljsKeyword("RxImageData")
            .appendHljsName(".bitmap")
            .append("(")
            .appendHljsKeyword("bitmap")
            .append(")").append(System.lineSeparator())
            .appendHljsName("      .addFilter")
            .append("(")
            .appendHljsKeyword("new  NatureFilter()")
            .append(")")
            .append(System.lineSeparator())
            .appendHljsName("      .into")
            .append("(")
            .appendHljsKeyword("image2")
            .append(");");
        return codeBuilder.build();
    }
}
